/*
 * Powered By [rapid-framework]
 * Web Site: http://www.rapid-framework.org.cn
 * Google Code: http://code.google.com/p/rapid-framework/
 * Since 2008 - 2013
 */

package com.gxuwz.byssxsys.dao;

import javacommon.base.BaseHibernateDao;

import org.springframework.stereotype.Repository;

import cn.org.rapid_framework.page.Page;
import cn.org.rapid_framework.page.PageRequest;

import com.gxuwz.byssxsys.model.Admin;

@Repository
public class AdminDao extends BaseHibernateDao<Admin,java.lang.Integer>{

	public Class<Admin> getEntityClass() {
		return Admin.class;
	}
	
	public Page<?> findPage(/*AdminQuery*/PageRequest<?> query) {
        //XsqlBuilder syntax,please see http://code.google.com/p/rapid-xsqlbuilder
        // [column]为字符串拼接, {column}为使用占位符. [column]为使用字符串拼接,如username='[username]',偷懒时可以使用字符串拼接 
        // [column] 为PageRequest的属性
		String sql = "select t from Admin t where 1=1 "
			  	+ "/~ and t.adminName = {adminName} ~/"
			  	+ "/~ and t.adminPassword = {adminPassword} ~/"
				+ "/~ order by [sortColumns] ~/";

        //生成sql2的原因是为了不喜欢使用xsqlbuilder的同学，请修改生成器模板，删除本段的生成
//        StringBuilder sql2 = new StringBuilder("select t from Admin t where 1=1 ");
//        if(isNotEmpty(query.getId())) {
//            sql2.append(" and  t.id = :id ");
//        }
//        if(isNotEmpty(query.getAdminName())) {
//            sql2.append(" and  t.adminName = :adminName ");
//        }
//        if(isNotEmpty(query.getAdminPassword())) {
//            sql2.append(" and  t.adminPassword = :adminPassword ");
//        }
//        if(isNotEmpty(query.getSortColumns())) {
//            sql2.append(" order by :sortColumns ");
//        }	
        
		return pageQuery(sql,query);
	}
	

}
